package me.sdau.spider.openapi.dto;

import lombok.Data;

import java.util.List;

@Data
public class Result<T> {
    /**
     * 数据
     */
    private List<T> data;
    /**
     * 数据条数
     */
    private int total;
    /**
     * 消息
     */
    private String message;

    private Result(List<T> data) {
        this.data = data;
        this.total = data.size();
    }

    private Result(String message) {
        this.message = message;
    }

    public static <T> Result<T> of(List<T> list) {
        return new Result<>(list);
    }

    public static Result of(String message) {
        return new Result(message);
    }
}
